const Controller = require('egg').Controller
const path = require('path')

class FileController extends Controller {
  /* 后台 */
  async getFiles() {
    const { ctx } = this
    const { file, directory }= ctx.request.body
    // 路径为 /app
    const fullStaticPath = path.resolve(__dirname, '../../')
    const content = ctx.service.file.content(directory, fullStaticPath)
    const mime = ctx.service.file.parseMime(file)
    
    ctx.body = {
      code: '0',
      desc: '获取成功',
      content: content,
      mime: mime
    }
  }
}

module.exports = FileController